package com.demo.task.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.demo.task.R;
import com.demo.task.core.BackService;
import com.demo.task.core.SuperActivity;

import java.util.HashMap;

/**
 * 作者： andli
 * 时间： 2017/11/7 14:20
 * 描述： 首页
 */
public class MainActivity extends SuperActivity {

    Button loginButton;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 启动服务
        Intent service = new Intent(MainActivity.this, BackService.class);
        startService(service);

        loginButton = (Button) findViewById(R.id.frame_login_button);

        loginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                HashMap<String, Object> param = new HashMap<String, Object>();
                param.put("username", "test");
                param.put("password", "11111");
                new LoginTask(MainActivity.this, param);
            }
        });
    }


    @Override
    public void refresh(Object... param) {
        String bs = param[0].toString();
        Toast.makeText(this, bs, Toast.LENGTH_SHORT).show();
        Log.i("andli", bs);
    }


}
